<template>
  <div id="goodlist">
    <van-empty description="暂无商品" v-show="itemList.length == 0" />
    <div class="mainlist">
      <van-card
        v-for="item in itemList"
        :key="item.id"
        :price="item.price"
        :origin-price="item.market_price"
        :desc="item.goodsname"
        :title="item.goodsname"
        :thumb="item.img"
        @click="toDetail(item.id)"
      />
    </div>
  </div>
</template>

<script>
import topSearch from "../components/topsearch.vue";
import { mapGetters } from "vuex";
export default {
  data() {
    return {};
  },
  computed: {
    ...mapGetters({ itemList: "getItemList" }),
  },
  components: {
    topSearch,
  },
  methods: {
    toDetail(id) {
      this.$router.push({
        path: "/detail",
        query: { id },
      });
    },
  },
};
</script>

<style scoped>
</style>